#include <bits/stdc++.h>
using namespace std;

struct node {
    unsigned int num, cnt;
    node* next[2];
    node()
        : num(0)
        , cnt(0)
    {
        next[0] = next[1] = NULL;
    }
};

int n, m;
unsigned int prefix[600005];
node* tree[600005];

unsigned int dfs(node* t1, node* t2, unsigned int x)
{
    node *c1 = t1, *c2 = t2;
    for (int i = 31; i >= 0; i--) {
        bool v = !((x >> i) & 1);

        if (c2->next[v] && (!c1 || !c1->next[v] || c2->next[v]->cnt > c1->next[v]->cnt)) {
            c2 = c2->next[v];
            if (c1)
                c1 = c1->next[v];
        } else {
            c2 = c2->next[!v];
            if (c1)
                c1 = c1->next[!v];
        }
    }
    return c2->num;
}

void insert(node* old_tree, node* new_tree, unsigned val)
{
    node *p1 = old_tree, *p2 = new_tree;
    for (int k = 31; k >= 0; k--) {
        int bit = (val >> k) & 1;

        if (p1)
            p2->next[!bit] = p1->next[!bit];

        if (!p1 || !p1->next[bit]) {
            p2->next[bit] = new node();
        } else {
            p2->next[bit] = new node();
            *p2->next[bit] = *p1->next[bit];
        }

        if (p1)
            p1 = p1->next[bit];
        p2 = p2->next[bit];
        p2->cnt++;
    }
    p2->num = val;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;

    prefix[0] = 0;
    for (int i = 1; i <= n; i++) {
        unsigned int x;
        cin >> x;
        prefix[i] = prefix[i - 1] ^ x;
    }

    tree[0] = new node();
    insert(nullptr, tree[0], 0);

    for (int i = 1; i <= n; i++) {
        tree[i] = new node();
        insert(tree[i - 1], tree[i], prefix[i]);
    }

    int cnt = n;
    for (int i = 1; i <= m; i++) {
        char type;
        cin >> type;

        if (type == 'A') {
            unsigned int x;
            cin >> x;
            cnt++;
            prefix[cnt] = prefix[cnt - 1] ^ x;
            tree[cnt] = new node();
            insert(tree[cnt - 1], tree[cnt], prefix[cnt]);
        } else {
            int l, r;
            unsigned int x;
            cin >> l >> r >> x;

            unsigned int query_val = x ^ prefix[cnt], result;
            if (l == 1)
                result = dfs(nullptr, tree[r - 1], query_val);
            else
                result = dfs(tree[l - 2], tree[r - 1], query_val);
            cout << (result ^ query_val) << "\n";
        }
    }

    return 0;
}